[BUILDER]: Initialize code segment selectors in virtual IDT to 0.
authorIan Campbell <ian.campbell@xensource.com>
Thu, 8 Mar 2007 15:35:28 +0000 (15:35 +0000)
committerIan Campbell <ian.campbell@xensource.com>
Thu, 8 Mar 2007 15:35:28 +0000 (15:35 +0000)
These should not be set until the guest kernel kernel configures an
entry point otherwise the null_trap_bounce() check gets confused.

This change was made to the old domain builder in 12455:3fa6635d04b9
but was lost in the transition to the new builder.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
tools/libxc/xc_dom_x86.c

index 695e5a168dbd23ab1a9002dec4e3fa3e797f08e5..19296daf10d0afe9f8c7d00e7686ba1c8c458707 100644 (file)
@@ -433,24 +433,12 @@ static int vcpu_x86_32(struct xc_dom_image *dom, void *ptr)
 {
     vcpu_guest_context_x86_32_t *ctxt = ptr;
     xen_pfn_t cr3_pfn;
-    int i;
 
     xc_dom_printf("%s: called\n", __FUNCTION__);
 
     /* clear everything */
     memset(ctxt, 0, sizeof(*ctxt));
 
-    /* Virtual IDT is empty at start-of-day. */
-    for ( i = 0; i < 256; i++ )
-    {
-        ctxt->trap_ctxt[i].vector = i;
-        ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_32;
-    }
-
-    /* No callback handlers. */
-    ctxt->event_callback_cs = FLAT_KERNEL_CS_X86_32;
-    ctxt->failsafe_callback_cs = FLAT_KERNEL_CS_X86_32;
-
     ctxt->user_regs.ds = FLAT_KERNEL_DS_X86_32;
     ctxt->user_regs.es = FLAT_KERNEL_DS_X86_32;
     ctxt->user_regs.fs = FLAT_KERNEL_DS_X86_32;
@@ -464,9 +452,8 @@ static int vcpu_x86_32(struct xc_dom_image *dom, void *ptr)
         dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
     ctxt->user_regs.eflags = 1 << 9; /* Interrupt Enable */
 
-    ctxt->kernel_ss = FLAT_KERNEL_SS_X86_32;
-    ctxt->kernel_sp =
-        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
+    ctxt->kernel_ss = ctxt->user_regs.ss;
+    ctxt->kernel_sp = ctxt->user_regs.esp;
 
     ctxt->flags = VGCF_in_kernel_X86_32;
     if ( dom->parms.pae == 2 /* extended_cr3 */ ||
@@ -485,20 +472,12 @@ static int vcpu_x86_64(struct xc_dom_image *dom, void *ptr)
 {
     vcpu_guest_context_x86_64_t *ctxt = ptr;
     xen_pfn_t cr3_pfn;
-    int i;
 
     xc_dom_printf("%s: called\n", __FUNCTION__);
 
     /* clear everything */
     memset(ctxt, 0, sizeof(*ctxt));
 
-    /* Virtual IDT is empty at start-of-day. */
-    for ( i = 0; i < 256; i++ )
-    {
-        ctxt->trap_ctxt[i].vector = i;
-        ctxt->trap_ctxt[i].cs = FLAT_KERNEL_CS_X86_64;
-    }
-
     ctxt->user_regs.ds = FLAT_KERNEL_DS_X86_64;
     ctxt->user_regs.es = FLAT_KERNEL_DS_X86_64;
     ctxt->user_regs.fs = FLAT_KERNEL_DS_X86_64;
@@ -512,9 +491,8 @@ static int vcpu_x86_64(struct xc_dom_image *dom, void *ptr)
         dom->parms.virt_base + (dom->start_info_pfn) * PAGE_SIZE_X86;
     ctxt->user_regs.rflags = 1 << 9; /* Interrupt Enable */
 
-    ctxt->kernel_ss = FLAT_KERNEL_SS_X86_64;
-    ctxt->kernel_sp =
-        dom->parms.virt_base + (dom->bootstack_pfn + 1) * PAGE_SIZE_X86;
+    ctxt->kernel_ss = ctxt->user_regs.ss;
+    ctxt->kernel_sp = ctxt->user_regs.esp;
 
     ctxt->flags = VGCF_in_kernel_X86_64;
     cr3_pfn = xc_dom_p2m_guest(dom, dom->pgtables_seg.pfn);